import { request } from "@umijs/max";

//获取全部的字典组列表
export const getDictionaryGroupList = () =>
  request(`/dictionaryGroup/list`, {
    method: "GET",
  });

//新增或修改字典组
export const editDictionaryGroup = (params:{
      /**
     * 描述
     */
      description?: null | string;
      /**
       * 字典组ID
       */
      id?: number | null;
      /**
       * 字典组名称
       */
      name?: null | string;
      /**
       * 字典组别名
       */
      slug?: null | string;
}) =>
  request(`/dictionaryGroup/add-or-update`, {
    method: "POST",
    data: params,
  });

//删除字典项
export const delDictionaryGroup = (id: any) =>
  request(`/dictionaryGroup/${id}`, {
    method: "DELETE",
  });

//根据分组ID获取该组下的所有字典项
export const getDictionaryItemList = (groupId: any) =>
  request(`/dictionaryItem/list/${groupId}`, {
    method: "GET",
  });

//新增或修改字典项
export const editDictionaryItem = (params: {
      /**
     * 描述
     */
      description?: null | string;
      /**
       * 字典组ID
       */
      id?: number | null;
      /**
       * 字典组名称
       */
      name?: null | string;
      /**
       * 字典组别名
       */
      slug?: null | string;
}) =>
  request(`/dictionaryItem/add-or-update`, {
    method: "POST",
    data: params,
  });

//删除字典项
export const delDictionaryItem = (id: any) =>
  request(`/dictionaryItem/${id}`, {
    method: "DELETE",
  });
